<template>
  <div class="time">
    <div class="time-container">
      <div class="time-icon" />
      <label
        id="date"
        name="date"
        class="datepicker"
        type="text"
        autocomplete="off"
        lay-verify="date"
        placeholder="yyyy-MM-dd"
      />
    </div>
    <button
      class="search"
      @click="clickHandler"
    >
      <i class="el-icon-search" />
    </button>
  </div>
</template>

<script>
// import VueTypes from 'vue-types'
// import { css } from 'styled-vue'
import laydate from 'laydate-es6'
import dayjs from 'dayjs'
export default {
  name: 'DatePicker',
  props: {},
  data() {
    return {
      date: dayjs().format('YYYY-MM-DD')
    }
  },
  mounted() {
    //  this.$emit('getZoom', zoom)
    laydate.render({
      elem: '#date',
      type: 'date',
      value: new Date(),
      min: -5, // 7天前
      max: 9, // 7天后
      format: 'yyyy-MM-dd', // 可任意组合
      done: (value, date, endDate) => {
        this.date = value
      }
    })
  },
  methods: {
    clickHandler() {
      this.$emit('getDate', this.date)
    }
  }
}
</script>

<style scoped>
.time {
  position: absolute;
  z-index: 1;
  background: #ffffff;
  left: 2em;
  top: 2.1rem;
  width: 340px;
  height: 36px;
  box-shadow: 0 0 10px hsla(0, 0%, 40%, 0.25);
  line-height: 36px;
  font-size: 14px;
}
.time-container {
  border: 1px solid #a8a8a8;
  height: 32px;
  display: inline-block;
  vertical-align: middle;
  line-height: 32px;
  margin-left: 12px;
  font-size: 0;
  border: none;
}
.search {
  width: 80px;
  height: 36px;
  background: #3590f9;
  color: #fff;
  line-height: 32px;
  cursor: pointer;
  display: inline-block;
  vertical-align: middle;
  text-align: center;
  border-width: 0px;
  position: absolute;
  right: 0;
  font-size: 20px;
}
.search:hover {
  color: #33c1ff;
}
.time-icon {
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml,%3Csvg class='icon' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M512 810.667a42.667 42.667 0 1 0 0-85.334 42.667 42.667 0 0 0 0 85.334zm213.333 0a42.667 42.667 0 1 0 0-85.334 42.667 42.667 0 0 0 0 85.334zm0-170.667a42.667 42.667 0 1 0 0-85.333 42.667 42.667 0 0 0 0 85.333zM512 640a42.667 42.667 0 1 0 0-85.333A42.667 42.667 0 0 0 512 640zm298.667-512H768V85.333a42.667 42.667 0 1 0-85.333 0V128H341.333V85.333a42.667 42.667 0 1 0-85.333 0V128h-42.667a128 128 0 0 0-128 128v597.333a128 128 0 0 0 128 128h597.334a128 128 0 0 0 128-128V256a128 128 0 0 0-128-128zm42.666 725.333A42.667 42.667 0 0 1 810.667 896H213.333a42.667 42.667 0 0 1-42.666-42.667v-384h682.666v384zm0-469.333H170.667V256a42.667 42.667 0 0 1 42.666-42.667H256V256a42.667 42.667 0 0 0 85.333 0v-42.667h341.334V256A42.667 42.667 0 1 0 768 256v-42.667h42.667A42.667 42.667 0 0 1 853.333 256v128zM298.667 640a42.667 42.667 0 1 0 0-85.333 42.667 42.667 0 0 0 0 85.333zm0 170.667a42.667 42.667 0 1 0 0-85.334 42.667 42.667 0 0 0 0 85.334z' fill='%23817f7f'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  display: inline-block;
  margin-left: 10px;
  vertical-align: middle;
}
.datepicker {
  display: inline-block;
  padding-left: 10px;
  line-height: 1.3;
  background-color: #fff;
  border-radius: 2px;
  border: none;
  width: 125px;
  vertical-align: middle;
  font: 14px Helvetica Neue, Helvetica, PingFang SC, \5fae\8f6f\96c5\9ed1,
    Tahoma, Arial, sans-serif;
  cursor: pointer;
}
</style>
<style >
.layui-laydate {
  margin-top: 1.1em;
}
.layui-laydate .layui-this {
  background-color: #5253fb !important;
}
.layui-laydate .laydate-disabled,
.layui-laydate .laydate-disabled:hover {
  background: none !important;
}
.layui-laydate-footer span:hover {
  color: #5253fb;
}
.layui-laydate-header i:hover,
.layui-laydate-header span:hover {
  color: #5253fb;
}
</style>
